﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class UIGameHandler : MonoBehaviour {

    public GameObject Player;  //玩家引用

    private GameObject GameOverMenu; //游戏结束UI
  
    public int score = 0;
    // Use this for initialization
    void Start () {
        Player = GameObject.FindWithTag("Player");
        GameOverMenu = GameObject.Find("Canvas/GameOverMenu");
        GameOverMenu.SetActive(false);

    }

    void Update()
    {
       // Debug.Log(PlayerMove._instance.isDie);
        if (PlayerMove._instance.isDie)
        {
            UITimedao.instance.gameObject.SetActive(true);
            GameOverMenu.SetActive(true);
            PlayerMove._instance.isDie = false;
        }
    }

    //继续游戏
    public void GoOn()
    {
        Player.transform.position = PlayerMove._instance.PlayerPos;

        //金币减少
        PlayerMove.gold -= 2;
        //倒计时页面消失
        UITimedao.instance.gameObject.SetActive(false);
        GameOverMenu.SetActive(false);
    }

    /// <summary>
    /// 游戏结束跳到开始界面
    /// </summary>
    public void GameOver()
    {
        SceneManager.LoadScene(0);
    }

}
